{extend name="base"/}
{block name="resources"}
<style>
	.required { margin-right: 3px; }
	.ns-check-member { position: relative; }
	.ns-check-member .layui-btn { position: absolute; top: 0; right: 1px; border-color: #e5e5e5; padding: 0 10px; border-right: 0; }
	
	.ns-store-company, .ns-pay-company, .ns-pay-alipay, .ns-shop-own { display: none; }

	/* 关联会员 */
	.ns-search-result { border: 1px solid; padding: 15px 30px 15px 15px; display: flex; align-items: center; position: relative;margin-top:10px; }
	.ns-search-res-img { width: 50px; height: 50px; margin-right: 5px; text-align: center; line-height: 50px; }
	.ns-search-res-img img { max-width: 100%; max-height: 100%; }
	.ns-search-res-intro p { line-height: 24px; }
	.ns-search-res-close { position: absolute; top: 5px; right: 5px; }
	
	.ns-card-common:first-of-type {margin-top: 0;}
	.ns-form-row {margin-top: 0;}
	.ns-check-member .layui-input:focus+.layui-btn {border-color: #4685FD;}
	.ns-store-company, .ns-pay-company{margin-top: 10px;}
</style>
{/block}
{block name="main"}
<div class="layui-form">
	<!-- 店铺信息 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">店铺信息</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>店铺名称：</label>
				<div class="layui-input-block">
					<input name="site_name" type="text" lay-verify="required" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>主营行业：</label>
				<div class="layui-input-block ns-len-mid">
					<select class="ns-category" name="category_id" lay-verify="required">
						<option value="">选择主营行业</option>
						{volist name="$shop_category_list" id="category"}
						<option value="{$category.category_id}">{$category.category_name}</option>
						{/volist}
					</select>
				</div>
			</div>

			<!--是否为自营-->
			<div class="layui-form-item">
				<label class="layui-form-label">是否自营：</label>
				<div class="layui-input-block" id="is_own">
					<input type="radio" name="is_own" lay-filter="is_own" value="0" title="否" checked>
					<input type="radio" name="is_own" lay-filter="is_own" value="1" title="是" >
				</div>
			</div>
			
			<!-- 商家主营等级 -->
			<div class="layui-form-item ns-shop-is-own">
				<label class="layui-form-label"><span class="required">*</span>开店套餐：</label>
				<div class="layui-input-block ns-len-mid">
					<select class="ns-group" name="no_group_id" lay-verify="required" lay-filter="group">
						<option value=""></option>
						{volist name="$shop_group_list" id="group"}
						<option value="{$group.group_id}" title="{$group.is_own}">{$group.group_name}</option>
						{/volist}
					</select>
				</div>
			</div>
			
			<!-- 商家自营等级 -->
			<div class="layui-form-item ns-shop-own">
				<label class="layui-form-label"><span class="required">*</span>开店套餐：</label>
				<div class="layui-input-block ns-len-mid">
					<select class="ns-group" name="group_id" lay-filter="group">
						<option value=""></option>
						{volist name="$shop_own_group" id="group"}
						<option value="{$group.group_id}" title="{$group.is_own}">{$group.group_name}</option>
						{/volist}
					</select>
				</div>
			</div>

			<div class="layui-form-item ns-shop-time">
				<label class="layui-form-label"><span class="required">*</span>入驻时长：</label>
				<div class="layui-input-block ns-len-mid">
					<select name="year" lay-verify="required">
						<option value="">选择入驻时长</option>
						<option value="1">一年</option>
						<option value="2">二年</option>
						<option value="3">三年</option>
						<option value="4">四年</option>
						<option value="5">五年</option>
					</select>
				</div>
			</div>
		</div>
	</div>
	
	<!-- 申请类型 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">申请类型</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item">
				<label class="layui-form-label">申请类型：</label>
				<div class="layui-input-block" id="cert_type">
					<input type="radio" name="cert_type" lay-filter="certType" value="1" title="个人店铺" checked>
					<input type="radio" name="cert_type" lay-filter="certType" value="2" title="企业店铺" >
				</div>
			</div>
		</div>
	</div>

	<!-- 企业店铺独有 -->
	<div class="ns-store-company">

		<!-- 企业信息 -->
		<div class="layui-card ns-card-common ns-card-brief">
			<div class="layui-card-header">
				<span class="ns-card-title">企业信息</span>
			</div>
			<div class="layui-card-body">
				<div class="layui-form-item">
					<label class="layui-form-label">公司名称：</label>
					<div class="layui-input-block">
						<input name="company_name" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item" data-flag="area">
					<label class="layui-form-label">公司地址：</label>
					<div class="layui-input-inline ns-len-mid">
						<select name="company_province_id" data-type="province" data-init="" lay-filter="comProvince"></select>
					</div>
					<div class="layui-input-inline ns-len-mid">
						<select name="company_city_id" data-type="city" data-init="" lay-filter="comCity"></select>
					</div>
					<div class="layui-input-inline ns-len-mid">
						<select name="company_district_id" data-type="district" data-init="" lay-filter="comDistrict"></select>
					</div>
				</div>
				<div class="layui-form-item" data-flag="area">
					<label class="layui-form-label">详细地址：</label>
					<div class="layui-input-inline">
						<input name="company_address" type="text" placeholder="请输入详细地址" class="layui-input ns-len-mid" autocomplete="off">
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- 公共部分 -->
	<!-- 联系人信息 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">联系人信息</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item">
				<label class="layui-form-label ns-company-name">联系人姓名：</label>
				<div class="layui-input-inline">
					<input name="contacts_name" type="text" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label ns-company-phone">联系人手机：</label>
				<div class="layui-input-block">
					<input name="contacts_mobile" type="text" lay-verify="mobile" class="layui-input ns-len-long" autocomplete="off">
				</div>
				<span class="ns-word-aux">请填写有效的手机号，如有问题可通过该手机号联系到商家</span>
			</div>
		</div>
	</div>

	<!-- 营业执照 税务 -->
	<!-- 企业店铺独有 -->
	<div class="ns-store-company">
		<div class="layui-card ns-card-common ns-card-brief">
			<div class="layui-card-header">
				<span class="ns-card-title">企业资质</span>
			</div>
			<div class="layui-card-body">
				<div class="layui-form-item">
					<label class="layui-form-label">统一社会信用码：</label>
					<div class="layui-input-block">
						<input name="business_licence_number" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
					<span class="ns-word-aux">请填写三证合一之后的营业执照上的统一社会信用代码</span>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label img-upload-lable">营业执照电子版：</label>
					<div class="layui-input-block img-upload">
						<input type="hidden" class="layui-input" name="business_licence_number_electronic" />
						<div class="upload-img-block icon">
							<div class="upload-img-box" id="license">
								<div class="ns-upload-default">
									<img src="__STATIC__/img/upload_img.png" />
									<p>点击上传</p>
								</div>
							</div>
						</div>
					</div>
					<span class="ns-word-aux">请上传营业执照传真图片或者照片，营业执照包括边框内容要全部显示，不能遮挡</span>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">法定经营范围：</label>
					<div class="layui-input-block ns-len-long">
						<textarea name="business_sphere" class="layui-textarea"></textarea>
					</div>
					<span class="ns-word-aux">经营范围（可填写营业执照上的经营范围内容）</span>
				</div>

				<!-- <div class="layui-form-item">
					<label class="layui-form-label">税务登记证号：</label>
					<div class="layui-input-block">
						<input name="tax_registration_certificate" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
					<span class="ns-word-aux">税务登记证号即为三证合一之后的营业执照上的统一社会信用代码，三证合一之前为税务登记证上的编码</span>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label img-upload-lable">税务登记证电子版：</label>
					<div class="layui-input-block img-upload">
						<input type="hidden" class="layui-input" name="tax_registration_certificate_electronic" />
						<div class="upload-img-block icon">
							<div class="upload-img-box" id="taxlicense">
								<div class="ns-upload-default">
									<img src="__STATIC__/img/upload_img.png" />
									<p>点击上传</p>
								</div>
							</div>
						</div>
					</div>
					<span class="ns-word-aux">税务登记证传真图片或者照片，包括边框在内的内容都需要显示</span>
				</div> -->
			</div>
		</div>
	</div>

	<!-- 身份证件 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">联系人身份证件</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item">
				<label class="layui-form-label ns-company-ident">联系人身份证号：</label>
				<div class="layui-input-inline">
					<input name="contacts_card_no" type="text" lay-verify="idcard" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label img-upload-lable ns-company-pic-front">申请人身份证正面：</label>
				<div class="layui-input-block img-upload">
					<input type="hidden" class="layui-input" name="contacts_card_electronic_2" />
					<div class="upload-img-block icon">
						<div class="upload-img-box" id="idCardPicFront">
							<div class="ns-upload-default">
								<img src="__STATIC__/img/upload_img.png" />
								<p>点击上传</p>
							</div>
						</div>
					</div>
				</div>
				<span class="ns-word-aux">上传申请人身份证正面，即有本人照片与身份证号的那一面</span>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label img-upload-lable ns-company-pic-back">申请人身份证反面：</label>
				<div class="layui-input-block img-upload">
					<input type="hidden" class="layui-input" name="contacts_card_electronic_3" />
					<div class="upload-img-block icon">
						<div class="upload-img-box" id="idCardPicBack">
							<div class="ns-upload-default">
								<img src="__STATIC__/img/upload_img.png" />
								<p>点击上传</p>
							</div>
						</div>
					</div>
				</div>
				<span class="ns-word-aux">上传申请人身份证反面，即有身份登记地址的那一面</span>
			</div>
		</div>
	</div>

	<!-- 对公账户信息 -->
	<!-- 企业店铺独有 -->
	<div class="ns-pay-company">
		<div class="layui-card ns-card-common ns-card-brief">
			<div class="layui-card-header">
				<span class="ns-card-title">对公账户</span>
			</div>
			<div class="layui-card-body">
				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>银行开户名：</label>
					<div class="layui-input-block">
						<input name="bank_account_name" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>公司银行账号：</label>
					<div class="layui-input-inline">
						<input name="bank_account_number" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>开户银行名称：</label>
					<div class="layui-input-inline">
						<input name="bank_name" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>
				
				<div class="layui-form-item" data-flag="area">
					<label class="layui-form-label"><span class="required">*</span>开户银行所在地：</label>
					<div class="layui-input-inline ns-len-mid">
						<select class="bank-province" data-type="province" data-init="" lay-filter="bankProvince"></select>
					</div>
					<div class="layui-input-inline ns-len-mid">
						<select class="bank-city" data-type="city" data-init="" lay-filter="bankCity"></select>
					</div>
					<div class="layui-input-inline ns-len-mid">
						<select class="bank-district" data-type="district" data-init="" lay-filter="bankDistrict"></select>
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- 结算信息 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">结算账户</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item">
				<label class="layui-form-label">结算账户类型：</label>
				<div class="layui-input-inline ns-len-mid">
					<input type="radio" name="bank_type" lay-filter="payType" value="1" title="银行卡" checked>
					<input type="radio" name="bank_type" lay-filter="payType" value="2" title="支付宝" >
				</div>
			</div>
			<!--银行卡-->
			<div class="ns-pay-bank">
				<div class="layui-form-item">
					<label class="layui-form-label ns-pay-alipay-name"><span class="required">*</span>结算银行开户名：</label>
					<div class="layui-input-inline">
						<input name="settlement_bank_account_name" id="settlement_bank_account_name" lay-verify="required" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label ns-pay-alipay-account"><span class="required">*</span>结算公司银行账号：</label>
					<div class="layui-input-inline">
						<input name="settlement_bank_account_number" id="settlement_bank_account_number" lay-verify="required" type="text" lay-verify="required" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>结算开户银行名称：</label>
					<div class="layui-input-inline">
						<input name="settlement_bank_name" id="settlement_bank_name" type="text" class="layui-input ns-len-long" autocomplete="off" lay-verify="required">
					</div>
				</div>

				<div class="layui-form-item" data-flag="area">
					<label class="layui-form-label"><span class="required">*</span>结算开户银行所在地：</label>
					<div class="layui-input-inline ns-len-mid">
						<select data-type="province" data-init="" lay-filter="bankProvSecond" lay-verify="bankprovince"></select>
					</div>
					<div class="layui-input-inline ns-len-mid">
						<select data-type="city" data-init="" lay-filter="bankCitySecond" lay-verify="bankcity"></select>
					</div>
					<div class="layui-input-inline ns-len-mid">
						<select data-type="district" data-init="" lay-filter="bankDisSecond" lay-verify="bankdistrict"></select>
					</div>
				</div>
			</div>
			<!-- 支付宝 -->
			<div class="ns-pay-zfb" style="display: none">
				<div class="layui-form-item">
					<label class="layui-form-label ns-pay-alipay-name"><span class="required">*</span>支付宝用户名：</label>
					<div class="layui-input-inline">
						<input name="zfb_settlement_bank_account_name" id="settlement_zfb_account_name"  type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label ns-pay-alipay-account"><span class="required">*</span>支付宝账号：</label>
					<div class="layui-input-inline">
						<input name="zfb_settlement_bank_account_number" id="settlement_zfb_account_number" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- 个人信息 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">用户信息</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>商家登录用户名：</label>
				<div class="layui-input-ns">
					<input name="username" type="text" lay-verify="required" class="layui-input ns-len-long" autocomplete="off">
				</div>
				<span class="ns-word-aux">用于登录商家后台</span>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>商家登录密码：</label>
				<div class="layui-input-inline">
					<input name="password" type="text" lay-verify="required" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>
		</div>
	</div>

	<div class="ns-single-filter-box">
		<div class="ns-form-row">
			<button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
			<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
		</div>
	</div>
	
	<!-- 隐藏域 -->
	<input type="hidden" name="contacts_card_electronic_2" />   <!-- 身份证正面 -->
	<input type="hidden" name="contacts_card_electronic_3" />   <!-- 身份证反面 -->
	<input type="hidden" name="business_licence_number_electronic" />   <!-- 营业执照电子版 -->
	<!-- <input type="hidden" name="tax_registration_certificate_electronic" /> -->   <!-- 税务登记证号电子版 -->
</div>
{/block}
{block name="script"}
<script src="ADMIN_JS/address.js"></script>
<script>
	layui.use(['form', 'upload'], function() {
		var form = layui.form,
			$ = layui.jquery,
			payType = 1, //结算类型
			autotrophy = 0,//自营类型
			upload = layui.upload,
			repeat_flag = false; //防重复标识

		form.render();

		initArea(form); //三级联动初始化

		// 申请人身份证正面
		var uploadInst = upload.render({
			elem: '#idCardPicFront',
			url: ns.url("admin/upload/upload"),
			done: function(res) {
				if (res.code >= 0) {
					$("input[name='contacts_card_electronic_2']").val(res.data.pic_path);
					$("#idCardPicFront").html("<img src=" + ns.img(res.data.pic_path) + " >");
				}
				return layer.msg(res.message);
			}
		});

		// 申请人身份证反面
		var uploadInst = upload.render({
			elem: '#idCardPicBack',
			url: ns.url("admin/upload/upload"),
			done: function(res) {
				if (res.code >= 0) {
					$("input[name='contacts_card_electronic_3']").val(res.data.pic_path);
					$("#idCardPicBack").html("<img src=" + ns.img(res.data.pic_path) + " >");
				}
				return layer.msg(res.message);
			}
		});

		//营业执照电子版
		var uploadInst = upload.render({
			elem: '#license',
			url: ns.url("admin/upload/upload"),
			done: function(res) {
				if (res.code >= 0) {
					$("input[name='business_licence_number_electronic']").val(res.data.pic_path);
					$("#license").html("<img src=" + ns.img(res.data.pic_path) + " >");
				}
				return layer.msg(res.message);
			}
		});

		//税务登记证电子版
		var uploadInst = upload.render({
			elem: '#taxlicense',
			url: ns.url("admin/upload/upload"),
			done: function(res) {
				if (res.code >= 0) {
					$("input[name='tax_registration_certificate_electronic']").val(res.data.pic_path);
					$("#taxlicense").html("<img src=" + ns.img(res.data.pic_path) + " >");
				}
				return layer.msg(res.message);
			}
		});

		/**
		 * 监听提交
		 */
		form.on('submit(save)', function(data) {
			var bank_address = '', settlement_bank_address = '';

			data.field.category_name = $("select[name=category_id] option:selected").text();
			data.field.group_name = $("select[name=group_id] option:selected").text();
			if(autotrophy == 0){
				data.field.group_name = $("select[name=no_group_id] option:selected").text();
				data.field.group_id = data.field.no_group_id;
			}

			//对公账户
			bank_address += $("select[lay-filter=bankProvince] option:selected").text();
			bank_address += $("select[lay-filter=bankCity] option:selected").text();
			bank_address += $("select[lay-filter=bankDistrict] option:selected").text();
			data.field.bank_address = bank_address;

			//结算账户
			settlement_bank_address += $("select[lay-filter='bankProvSecond'] option:selected").text();
			settlement_bank_address += $("select[lay-filter='bankCitySecond'] option:selected").text();
			settlement_bank_address += $("select[lay-filter='bankDisSecond'] option:selected").text();
			data.field.settlement_bank_address = settlement_bank_address;

			if(payType == 2){
				data.field.settlement_bank_account_name = data.field.zfb_settlement_bank_account_name;
				data.field.settlement_bank_account_number = data.field.zfb_settlement_bank_account_number;
			}
			if (repeat_flag) return false;
			repeat_flag = true;
			//添加
			$.ajax({
				type: 'POST',
				url: ns.url("admin/shop/addShop"),
				data: data.field,
				dataType: 'JSON',
				success: function(res) {
					repeat_flag = false;
					if (res.code == 0) {
						layer.confirm('添加成功', {
							title:'操作提示',
							btn: ['返回列表', '继续添加'],
							yes: function(){
								location.href = ns.url("admin/shop/lists")
							},
							btn2: function() {
								location.href = ns.url("admin/shop/addShop")
							}
						});
					} else {
						layer.msg(res.message);
					}
				}
			});
		});

		/**
		 * select监听
		 */
		form.on('radio(is_own)', function(data) { //店铺等级中如果is_own=1，则入驻时长可以不填，否则必选
			autotrophy = data.value;
			//判断入驻时长是否必填,如果分组is_own=1 不必填 0 必填
			if (autotrophy == 0) {
				$(".ns-shop-time").show();
				$(".ns-shop-is-own").show();
				$(".ns-shop-own").hide();
				$(".ns-shop-time select").attr("lay-verify", "required");
				$(".ns-shop-is-own .ns-group").attr("lay-verify", "required");
				$(".ns-shop-own .ns-group").removeAttr("lay-verify");
			} else {
				$(".ns-shop-time").hide();
				$(".ns-shop-is-own").hide();
				$(".ns-shop-own").show();
				$(".ns-shop-time select").removeAttr("lay-verify");
				$(".ns-shop-is-own .ns-group").removeAttr("lay-verify");
				$(".ns-shop-own .ns-group").attr("lay-verify", "required");
			}
		});

		form.on('radio(certType)', function(data) { //为企业店铺时，显示企业独有部分，否则隐藏
			var value = data.value;
			if (value == 1) {
				$(".ns-store-company").hide();
				$(".ns-pay-company").hide();
				$(".ns-company-person").text("联系人信息");
				$(".ns-company-name").text("联系人姓名");
				$(".ns-company-phone").text("联系人电话");
				$(".ns-company-identity").text("联系人身份证件");
				$(".ns-company-ident").text("联系人身份证号");
				$(".ns-company-pic-front").text("申请人身份证正面");
				$(".ns-company-pic-back").text("申请人身份证反面");
			} else {
				$(".ns-store-company").show();
				$(".ns-pay-company").show();
				$(".ns-company-person").text("法人代表信息：");
				$(".ns-company-name").text("法人姓名：");
				$(".ns-company-phone").text("法人联系电话：");
				$(".ns-company-identity").text("法人身份证件：");
				$(".ns-company-ident").text("法人身份证号：");
				$(".ns-company-pic-front").text("法人身份证正面：");
				$(".ns-company-pic-back").text("法人身份证反面：");
			}
		});

		form.on('radio(payType)', function(data) { //判断支付方式，显示对应的表单
			payType = data.value;
			if (payType == 1) {
				$(".ns-pay-zfb").hide();
                $(".ns-pay-bank").show();

                $("#settlement_zfb_account_name").attr("lay-verify", "");
                $("#settlement_zfb_account_number").attr("lay-verify", "");
                $("#settlement_bank_account_name").attr("lay-verify", "required");
                $("#settlement_bank_account_number").attr("lay-verify", "required");
            	$("#settlement_bank_name").attr("lay-verify", "required");
            	$('.ns-pay-bank [data-type="province"]').attr("lay-verify", "bankprovince");
				$('.ns-pay-bank [data-type="city"]').attr("lay-verify", "bankcity");
				$('.ns-pay-bank [data-type="district"]').attr("lay-verify", "bankdistrict");
				form.render("select");
			} else {
				$(".ns-pay-bank").hide();
                $(".ns-pay-zfb").show();

                $("#settlement_zfb_account_name").attr("lay-verify", "required");
                $("#settlement_zfb_account_number").attr("lay-verify", "required");
                $("#settlement_bank_account_name").attr("lay-verify", "");
                $("#settlement_bank_account_number").attr("lay-verify", "");
                $("#settlement_bank_name").attr("lay-verify", "");
                $('.ns-pay-bank [data-type="province"]').attr("lay-verify", "");
				$('.ns-pay-bank [data-type="city"]').attr("lay-verify", "");
				$('.ns-pay-bank [data-type="district"]').attr("lay-verify", "");
			}
		});

		/**
		 * 表单验证
		 */
		form.verify({
			mobile: function(value) {
				var reg = /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/;
				if (value == '') {
					return;
				}
				if (!reg.test(value)) {
					return '请输入正确的手机号码!';
				}
			},
			idcard: function(value) {
				var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
				if (value == '') {
					return;
				}
				if (!reg.test(value)) {
					return '请输入正确的身份证号!';
				}
			},
			bankprovince: function(value){
				if (value == -1) return '请选择省';
			},
			bankcity: function(value){
				if (value == -1) return '请选择市';
			},
			bankdistrict: function(value, item){
				if (value == -1 && $(item).find('option').length > 1) return '请选择区县';
			},
		});

	});
	
	/**
	 * 点击搜索
	 */
	var repeat_flag = false;
	var html, val;

	function checkMember() {
		var parent = $(".ns-check-member");
		var con = parent.find(".ns-member-name").val();
		$(".layui-word-aux").remove();
		$(".ns-search-result").remove();

		if (repeat_flag) return false;
		repeat_flag = true;

		if (con == "" || con == null || con.trim() == "") {
			repeat_flag = false;
		} else {
			$.ajax({
				type: 'POST',
				url: ns.url("admin/member/searchMember"),
				data: {
					'search_text': con
				},
				dataType: 'JSON',
				success: function(res) {
					layer.msg(res.message);
					repeat_flag = false;

					if (res.data == null) {
						html = '<span class="layui-word-aux">未找到该用户</span>';
						val = res.data;
					} else {
						html = '<div class="ns-search-result layui-input-inline ns-border-color-gray">' +
							'<div class="ns-search-res-img">' +
							'<img src="' + ns.img(res.data.headimg) + '" />' +
							'</div>' +
							'<div class="ns-search-res-intro">' +
							'<p>用户名：' + res.data.username + '</p>' +
							'<p>电话：' + res.data.mobile + '</p>' +
							'</div>' +
							'<div class="ns-search-res-close" onclick="closeMember()">' +
							'<i class="iconfont iconclose_light"></i>' +
							'</div>' +
							'</div>';
						val = res.data.member_id;
					}

					$(".ns-member-id").attr("value", val);
					$(".ns-check-member").append(html);
				}
			});
		}
	}

	function closeMember() {
		$(".ns-search-result").hide();
	}
	
	function back() {
		location.href = ns.url("admin/shop/lists");
	}
</script>
{/block}